package com.xidian.zhiancloud.service.riskcontrol.riskstatistics;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.riskcontrol.riskstatistics.TRiskStatisticsMapper;
import com.xidian.zhiancloud.model.riskcontrol.RistStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;


@Service
public class TRiskStatisticsService extends ServiceImpl<TRiskStatisticsMapper, RistStatistics> {
    @Autowired
    TRiskStatisticsMapper tRiskStatisticsMapper;
    public HashMap<String,Object> getRiskStatistics(){
        HashMap<String,Object> map = new HashMap<>();
        Integer zhongda = 0;
        Integer jiaoda = 0;
        Integer yiban = 0;
        Integer di = 0;
        List<RistStatistics> riskStatistics = tRiskStatisticsMapper.getRiskStatistics();
        if (riskStatistics.size() > 0){
            map.put("tongjitu",riskStatistics);
            for(RistStatistics statistics : riskStatistics){
                if(TRiskStatisticsEX.ZHONGDA.equals(statistics.getRiskType())){
                    zhongda++;
                }
                if(TRiskStatisticsEX.JIAODA.equals(statistics.getRiskType())){
                    jiaoda++;
                }
                if(TRiskStatisticsEX.YIBAN.equals(statistics.getRiskType())){
                    yiban++;
                }
                if(TRiskStatisticsEX.DI.equals(statistics.getRiskType())){
                    di++;
                }
            }
            map.put("zhongda",zhongda);
            map.put("jiaoda",jiaoda);
            map.put("yiban",yiban);
            map.put("di",di);
        }
        return map;
    }
}
